import request from '@/config/axios'

export const getProcessDefinition = async (id?: string, key?: string) => {
  return await request.get({
    url: '/bpm/process-definition/get',
    params: { id, key }
  })
}

export const getProcessDefinitionPage = async (params) => {
  return await request.get({
    url: '/bpm/process-definition/page',
    params
  })
}

export const getProcessDefinitionList = async (params) => {
  return await request.get({
    url: '/bpm/process-definition/list',
    params
  })
}

export const getSimpleProcessDefinitionList = async () => {
  return await request.get({
    url: '/bpm/process-definition/simple-list'
  })
}

// 切换流程定义状态
export const toggleState = async (id: string, state: number) => {
  const data = {
    id: id,
    state: state
  }
  return await request.put({ url: '/bpm/process-definition/toggle-state', data: data })
}

// 切换流程定义状态
export const toggleVersion = async (id: string,modelId: string) => {
  const data = {
    id: id,
    modelId
  }
  return await request.put({ url: '/bpm/process-definition/toggle-version', data: data })
}

export const getBpmnModelView = async (id?: string) => {
  return await request.get({
    url: '/bpm/process-definition/get-bpmn-model-view',
    params: { id }
  })
}
